import Vue from 'vue'
import Router from 'vue-router'

import Main from '../components/Main.vue'
import Home from '../components/home/home.vue'
import ArticleList from '../components/article/list.vue'
import ArticleEdit from '../components/article/edit.vue'
import ClassifyList from '../components/classify/list.vue'
import ClassifyCreate from '../components/classify/create.vue'
import Login from '../components/login/login.vue'
import edituser from '../components/adminuser/edituser.vue'
import listuser from '../components/adminuser/listuser.vue'
import rulelist from '../components/rule/rule.vue'
import search from '../components/search/search.vue'


import store from '../store'
// import common from '../common'
Vue.use(Router)

// 解决element-ui点击同一个路由报错：NavigationDuplicated
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

const router = new Router({
	routes: [
		{
			path: '/',
			name: 'Main',
			component: Main,
			redirect: '/Home', // 后台菜单功能导航
			children:[ // 二级路由， // 菜单功能下级的页面
				{path: '/Home', component: Home},
				{path: '/article/list', component: ArticleList},
				{path: '/article/edit', component: ArticleEdit},
				{path: '/classify/list', component: ClassifyList},
				{path: '/classify/create', component: ClassifyCreate},
				{path: '/adminuser/edit', component: edituser},
				{path: '/adminuser/listuser', component: listuser},
				{path: '/rule/list', component: rulelist},
				{path: '/search/search', component: search}
			]
		},
		{ // 一级路由，与Home同级
			path: '/Login',
			component: Login,
			children: [{path: '/Login', component: Login}]
		}
	]
})

export default router;